package plateforme.controlleur;



import java.sql.Connection;

import javax.servlet.http.HttpServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 


import plateforme.connexion.ConnectionManager;

import plateforme.model.Projet;

/**
 * Servlet implementation class ControlleurAjouterProjet
 */
public class ControlleurAjouterProjet extends HttpServlet {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException 
	{
		
		
		String nom=request.getParameter("nom");
		String datedebut=request.getParameter("datedebut");
		
		String datefin= request.getParameter("detefin");
		String type= request.getParameter("type");
		
		Projet projet=new Projet();
		
		
		
		if((nom!=null) &&(datedebut!=null)&&(datefin!=null)){
		try{
			
		Connection cn=ConnectionManager.getConnection();
		java.sql.PreparedStatement pr=cn.prepareStatement("INSERT INTO project VALUES(NULL,?,?,?,?)");
		
		projet.setNom(nom);
		projet.setDatedebut(datedebut);
		projet.setDatefin(datefin);
		projet.setType(type);
		
		pr.setString(1,projet.getDatedebut());
		pr.setString(2,projet.getDatefin());
		pr.setString(3,projet.getNom());
		pr.setString(4, projet.getType());
		
		pr.execute();
		
		System.out.println(nom+datedebut+datefin);
		response.sendRedirect("chef_de_projet.jsp");
			
		
		
				
		} catch (Exception e) {
			// TODO: handle exception

		}
		
		
		
		
		
		
		}
		
		
	
	}
}
